<%@ page import="com.fuful.domain.Product" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>产品页</title>
    <style>
        #products td{
            width: 140px;
        }
        #products{
            margin:20px auto;

        }
        #main{
            width:800px;
            text-align: center;
        }
    </style>
</head>
<body>
<div id="main">
    <h3>产品列表</h3>
<table id="products" border="1">
    <tr>
        <td>编码</td>
        <td>名称</td>
        <td>类型</td>
        <td>价格</td>
        <td>操作</td>
    </tr>
    <%
        //获取共享对象
        List<Product> data = (ArrayList)session.getAttribute("productdata");
        for (Product p : data) {
    %>
    <tr>
        <td><%= p.getPcode()%></td>
        <td><%= p.getPname()%></td>
        <%--<td><a href="findPTypeProducts.do?ptid=<%= p.getPtid().getPtid()%>"><%= p.getPtid().getPtname()%></a></td>--%>
        <td><%= p.getPtid().getPtname()%></td>
        <td><%= p.getPprice()%></td>
        <%--<td><a href="addCart.do?pid=<%= p.getPid()%>">xxx</a></td>--%>
        <td>x x x</td>
    </tr>
    <%
        }
    %>
</table>
    <button id="increase">更多</button>
</div>
<script src="./js/jquery-3.4.1.min.js"></script>
<script>
    var position = 3;
    $("#increase").click(function () {

        $.ajax({
            url:"findProducts.do",
            type:"POST",
            data:"method=querySome&position="+position,
            dataType:"text",
            success:function (msg) {
                position += 3;
                $("#products").append(msg);
            }
        });
    });

</script>
</body>
</html>
